import { Reducer } from 'redux';

type activeToolbar =
  | 'layerlist'
  | 'daylight'
  | 'measure'
  | 'slice'
  | 'bimtree'
  | 'drawcolor'
  | 'basemap'
  | '';
export interface MaptoolbarModelState {
  activeToolbar?: activeToolbar;
  deactivate?: string;
  activeWidget?: any;
}

export interface ToolbarModelTypes {
  namespace: 'maptoolbar';
  state: MaptoolbarModelState;
  effects: {};
  reducers: {
    updataActiveToolbar: Reducer<MaptoolbarModelState>;
    measureSwitchModel: Reducer<MaptoolbarModelState>;
    weijiandom: Reducer<MaptoolbarModelState>;
  };
}

const MaptoolbarModel: ToolbarModelTypes = {
  namespace: 'maptoolbar',

  state: {
    activeToolbar: '', // 激活的工具状态
    deactivate: '',
    activeWidget: null,
  },

  effects: {},

  reducers: {
    updataActiveToolbar(state, action): MaptoolbarModelState {
      return { ...state, activeToolbar: action.payload };
    },
    measureSwitchModel(state, action): MaptoolbarModelState {
      return { ...state, deactivate: action.payload };
    },
    weijiandom(state, action): MaptoolbarModelState {
      return { ...state, activeWidget: action.payload };
    },
  },
};

export default MaptoolbarModel;
